/**
 * @description: 根据按键事件检测是否按下对应组合键
 * @param {KeyboardEvent} e 按键事件对象
 * @param {string} combinationStr 组合键例如 Ctrl+T (忽略大小写)
 * @return {boolean}
 */
export const isKeyboardCombination = (e: KeyboardEvent, combinationStr: string): boolean => {
  if(!combinationStr) return false

  const combinationList = combinationStr.split(/\s*\+\s*/);
  
  return combinationList.every((combinationKey) => {
    combinationKey = combinationKey.toLocaleLowerCase()
    
    if(combinationKey == 'ctrl') return !!e.ctrlKey
    else if(combinationKey == 'alt') return !!e.altKey
    else if(combinationKey == 'shift') return !!e.shiftKey
    else return combinationKey === e.key.toLocaleLowerCase()
  })
};